<html layout:decorate="~{project/arithmeticManage/arithmetic_list}" xmlns:layout="http://www.w3.org/1999/xhtml">
<script>

</script>
<div layout:fragment="arithmetic_list">

    <!--<div class="search_condition">-->
    <!--<form id="search-form">-->
    <!--<input class="search-data" name="Q_LIKE_name" type="text" placeholder="角色名称" >-->
    <!--<select class="search-data" name="Q_EQ_type.id">-->
    <!--<option value="">选择身份</option>-->
    <!--<option th:each="parameter:${parameters}" th:value="${parameter.id}" th:text="${parameter.name}"></option>-->
    <!--</select>-->
    <!--<button type="button" id="search-btn" class="btn btn-primary btn-search" >搜索</button>-->
    <!--</form>-->
    <!--</div>-->

    <div class="main-body">

        <div id="toolbar" class="btn-group btn-group-sm " >
            <a type="button" class="btn btn-success" data-toggle="modal" href="/project/arithmeticManage/arithmetic_import" data-target="#modal">
                <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>算法导入</a>

            <a type="button" class="btn btn-primary" data-toggle="modal"
               href="/project/arithmeticManage/manage_add" data-target="#modal3">新增</a>

            <a type="button" onclick="editData('/project/arithmeticManage/manage_edit','id')" class="btn btn-info">编辑</a>

            <a type="button" onclick="delDatas('/project/arithmeticManage/manage_delete')" class="btn btn-danger">删除</a>
        </div>

        <table id="dataTable" data-url="/project/arithmeticManage/manage_data" data-page-list=[]  data-striped="true"
               data-pagination="true" data-page-size="15" data-cache="false" data-toolbar-align="right" data-undefined-text="-">

        </table>

        <script>
            var dataFormat_point = [{
                checkbox: true
            },{
                field:'id',
                title:'id',
                visible:false
            },{
                field: 'name',
                title: '诊断算法名称',
                sortable:true
            },{
                field: 'objName',
                title: '对象',
                sortable:true,
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return '项目';
                    }
                    if (value == 2) {
                        return '电池包';
                    }
                    if (value == 3) {
                        return '电池模组';
                    }
                    if (value == 4) {
                        return '变流器';
                    }
                    if (value == 5) {
                        return '电池单体';
                    }
                    if (value == 6) {
                        return '平台';
                    }
                }
            }, {
                field: 'version',
                title: '版本',
                sortable:true
            }, {
                field: 'importTime',
                title: '导入时间',
                sortable:true,
                formatter:function(value,row,index){
                    return formatTimeStrap(value);
                }
            }, {
                field: 'remark',
                title: '备注',
                sortable:true
            }, {
                field: 'inOutParameter',
                title: '输入输出量',
                sortable:true,
                formatter:function(value,row,index){
                    if(row.inParameter!=null && row.outParameter!=null){
                        return row.inParameter+","+row.outParameter;
                    }
                }
//            }, {
//                field: 'subAlgorithm',
//                title: '关联子算法',
//                sortable:true
            }, {
                field: 'touchCondition',
                title: '默认触发条件',
                sortable:true
            }];

            window.onload = function () {
                getTable(dataFormat_point, "dataTable");
            };

            //修改按钮
            function editData(url,field,id) {
                var idResult = "dataTable";
                if(id){
                    idResult = id;
                }
                var table = $("#"+idResult).bootstrapTable('getSelections');
                if(table.length == 0){
                    alert("请选择一条记录");
                    return false;
                }else if(table.length > 1){
                    alert("只能选择一条记录");
                    return false;
                }
                var result = table[0][field];
                $("#modal3").modal({
                    remote:url+ "?"+field+"="+result
                });
            }
        </script>
    </div>
</div>
</html>

